<!DOCTYPE html>
<html>
<head>
    <title>二次认证</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="木兰湾管理系统">
    <script type="text/javascript" src="../../static/include/header-css.js"></script>
    <style>
        .button-sp-area{margin:15px auto;padding:15px;text-align:center}
        .button-sp-area.cell{padding:15px 0}
        .content{
            position:fixed;
            left:0;
            right:0;
        }
        .weui-vcode-btn{
             display:inline-block;
             height:40px;
             margin-left:5px;
             padding:0 0.6em 0 0.7em;
             border-left:0px solid #E5E5E5;
             line-height:45px;
             vertical-align:middle;
             font-size:17px;
             color:#3CC51F;
         }
        .weui-label2{
            display:block;
            width:120px;
            word-wrap:break-word;
            word-break:break-all;
        }
    </style>
</head>
<body class="content">
<br>
<div class="weui-cells__title" align="center">
    <img src="../../static/image/logo-large.png" alt="">
</div>
<div class="weui-cells__title" align="center">木兰湾管理系统</div>
<div class="weui-cells weui-cells_form">
    <form id="login-form">
        <div class="weui-cell mulanbay_select-before">
            <div class="weui-cell__hd">
                <img src="../../static/image/user.png">
            </div>
            <div class="weui-cell__hd">
                <label class="weui-label">认证方式</label>
            </div>
            <div class="weui-cell__bd">
                <label class="weui-label" id="secAuthType"></label>
            </div>
        </div>
        <div class="weui-cell mulanbay_select-before">
            <div class="weui-cell__hd">
                <img src="../../static/image/account2.png">
            </div>
            <div class="weui-cell__hd">
                <label class="weui-label">认证账户</label>
            </div>
            <div class="weui-cell__bd">
                <label class="weui-label" id="authAddress" style="width: 100%"></label>
            </div>
        </div>
        <div class="weui-cell mulanbay_select-before">
            <div class="weui-cell__hd">
                <img src="../../static/image/password.png"></img>
            </div>
            <div class="weui-cell__hd">
                <label class="weui-label">认证码</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="password" placeholder="请输入认证码" name="authCode" id="authCode">
            </div>
            <div class="weui-cell__ft">
                <div id="resendBtn"></div>
            </div>
        </div>
    </form>
</div>
<div class="button-sp-area">
    <a href="javascript:doAuth();" class="weui-btn weui-btn_primary">认证</a>
</div>
<script type="text/javascript" src="../../static/include/footer-js.js"></script>
<script type="text/javascript">
    $(function() {
        getSecAuthInfo();
    });
    function getSecAuthInfo(){
        var vurl ='/main/getSecAuthInfo';
        doAjax2(null,vurl,'GET',false,false,function(data){
            setElementInnerHTML('secAuthType',data.secAuthTypeName);
            setElementInnerHTML('authAddress',data.address);
            if(data.secAuthType!='PASSWORD'){
                setElementInnerHTML('resendBtn','<button  class="weui-vcode-btn" onclick="settime(this)">获取验证码</button>\n');
            }
        });
    }
    function doAuth(){
        var postData = {
            authCode: $("#authCode").val()
        };
        var vurl ='/main/secAuth';
        doAjax(postData,vurl,'POST',false,function(data){
            var returnUrl = getQueryVariable("returnUrl");
            if(returnUrl!=null&&returnUrl!=''){
                window.parent.location.href=returnUrl;
            }else {
                window.history.back();
            }
        });
    }
    function sendSecAuthCode(){
        var vurl ='/main/sendSecAuthCode';
        doAjax(null,vurl,'POST',false,function(data){
            $.toptip('已经发送', 'success');
        });
    }
    var countdown=60;
    function settime(obj) {
        var code = $(obj);
        if (countdown == 0) {
            code.removeAttr('disabled');
            code.text("获取认证码");
            countdown =60;
            return;
        } else {
            code.text("重新发送(" + countdown + ")");
            code.attr('disabled',true);
            countdown--;
        }
        if(countdown==59){
            sendSecAuthCode();
        }
        setTimeout(function() {
            settime(obj) }, 1000);
    }
</script>
</body>
</html>